﻿@extends('wechat.layouts.base')
@section("js_files")
    <script src="http://www.ebama.net/data/attachment/js/easing.js"></script>
    <script src="http://www.ebama.net/data/attachment/js/share_file.js"></script>
@endsection
@section('content')
	<!--信息提示弹窗-->
	<div class="weui_dialog_alert" style="display: none;">
		<div class="weui-mask"></div>
		<div class="weui-dialog" style="z-index=999999999999999; top:43%;">
			<div class="weui-dialog__hd"><strong class="weui-dialog__title">弹窗标题</strong></div>
			<div class="weui-dialog__bd">弹窗内容，告知当前页面信息等</div>
			<div class="weui-dialog__ft">
				<a id="ensure" href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
			</div>
		</div>
	</div>	
    <div id="mask">
        <div class="zhe"></div>
        <!--规则-->
        <div class="rule">
            <img src="https://ooo.0o0.ooo/2017/01/04/586c581063309.png" style=" width: 100%; ">
        </div>
    </div>
    <div class="list4">
        <div class="game">
            <ul class="numbox">
                <li class="num"></li>
                <li class="num"></li>
                <li class="num"></li>
                <li class="num"></li>
            </ul>
        </div>
        <div class="btn1">
            <input id="start" type="button" value=""/>
        </div>
        <!--<span id="res"></span>-->
    </div>
	<!--无缝滚动(后台数据)-->
		<div class="scroll" style="position:absolute; width:93%; top:66%; left:7%;">
			<ul id="Marquee" class="list2 gun">
			</ul>
		</div>

    <div class="btns clear">
        <a id="prizesearch" href="{{url('wechat/draw/prize')}}"></a>
        <a id="rule" href="javascript:;"></a>
    </div>
	<script src="{{asset('dist/wechat/js/prizelog.js')}}"></script>
	<script>
	//滚动设置
		onload = function(){
			sss(90,20);
		};
		var _picH = 90;

	</script>
        <script>
		$.weui = {};
		$.weui.alert = function(options){
			options = $.extend({title: '', text: '警告内容'}, options);
			var $alert = $('.weui_dialog_alert');
			$alert.find('.weui-dialog__title').text(options.title);
			$alert.find('.weui-dialog__bd').text(options.text);
			$alert.on('touchend click', '.weui-dialog__btn', function(){
				$alert.hide();
				//$("#start").attr("disabled",false);
			});
			$alert.show();
			//$("#start").attr("disabled",true);
		};
		$('.zhe,.rule img').on('click',function () {
			$('#mask').css('display','none');
			$('.rule').css('display','none')
		})
		$('#rule').on('click',function () {
					$('#mask').show();
					$('.rule').show();
				});
		$('#container').css({
			'background':'url("http://www.ebama.net/data/attachment/img/bg.jpg") no-repeat left top',
			'background-size':'100% 100%'
		});
        var numRand ;
        var rid;
        var isBegin = false;
        $(function(){
            var u = 102;
            $('#start').click(function(){
				$.weui.alert({text: "活动已结束！"});
				//return true;
               /*$.ajax({
                    url:"{{url('wechat/draw/rand')}}",
                    dataType: 'json',
                    async: false, //锁住浏览器,执行完毕后执行后面的方法
                    success:function (data) {
                        console.log(data)
                        if(data.success == true){
                            numRand = data.data.result;
                            rid =data.data.r_id;
							if(data.url){
								$('#ensure').attr('href',data.url);
							}else{
								$('#ensure').on('touchend click', function(){
									$(this).hide();
								});
							}
							setTimeout(function(){
								 $.weui.alert({text: data.data.data.name});
							},5200);
                        }else if(data.success == false){
                            numRand ="";
							if(data.url){
								$('#ensure').attr('href',data.url);
							}else{
								$('#ensure').on('touchend click', function(){
									$(this).hide();
								});
							}
							$.weui.alert({text: data.msg});
                            return false;
                        }
                    }
                });*/
                if(isBegin) return false;
                isBegin = true;
                $(".num:nth-of-type(1)").css('backgroundPositionY',-207);
                $(".num:nth-of-type(2)").css('backgroundPositionY',-3);
                $(".num:nth-of-type(3)").css('backgroundPositionY',-105);
                $(".num:nth-of-type(4)").css('backgroundPositionY',302);
                var result = numRand;
//                $('#res').text('随机摇奖结果 = '+result);
                var num_arr = (result+'').split('');
                $(".num").each(function(index){
                    var _num = $(this);
                    setTimeout(function(){
                        _num.animate({
                            backgroundPositionY: (u*60) - (u*num_arr[index])
                        },{
                            duration: 1000+index*1000,
                            easing: "easeInOutCirc",
                            complete: function(){
                                if(index==3) isBegin = false;
								}
						});
                    }, index * 300);
                });
                {{--$.ajax({--}}
                    {{--url:"{{url('wechat/draw/submit')}}",--}}
                    {{--data: {'rid': rid},--}}
                    {{--dataType: 'json',--}}
                    {{--async: false, //锁住浏览器,执行完毕后执行后面的方法--}}
                    {{--success: function (data) {--}}
                        {{--console.log(data);--}}
                    {{--}--}}
                {{--});--}}
            });
        });
    </script>
    @endsection
